from django.test import TestCase

# Create your tests here.

from django.urls import reverse

class CartViewsTestCase(TestCase):
    def test_add_view(self):
        response = self.client.get(reverse('web_cart_add', args=[1]))  # 假设要添加的商品的ID为1
        self.assertEqual(response.status_code, 302)  # 检查响应状态码，预期为重定向到首页

    def test_delete_view(self):
        response = self.client.get(reverse('web_cart_delete', args=[1]))  # 假设要删除的商品的ID为1
        self.assertEqual(response.status_code, 302)  # 检查响应状态码，预期为重定向到首页

    def test_clear_view(self):
        response = self.client.get(reverse('web_cart_clear'))
        self.assertEqual(response.status_code, 302)  # 检查响应状态码，预期为重定向到首页

    def test_change_view(self):
        response = self.client.get(reverse('web_cart_change'))
        self.assertEqual(response.status_code, 302)  # 检查响应状态码，预期为重定向到首页